package com.isunland.managesystem.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.RInappMain;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import com.isunland.managesystem.widget.CustomTextView;
import java.util.ArrayList;

/**
 * 对象功能:  零购入库adapter
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: HuXiaoDan
 * 创建时间: 2017/7/18 14:18
 */
public class RetailInAdapter extends BaseButterKnifeAdapter<RInappMain> {
  private Context context;

  public RetailInAdapter(BaseVolleyActivity context, ArrayList<RInappMain> objects) {
    super(context, objects);
    this.context = context;
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_out_list;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override protected void initView(RInappMain item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;
    holder.tvTitle1.setText(item.getMinCom());//概要
    holder.tvTitle1.setVisibility(TextUtils.isEmpty(item.getMinCom()) ? View.GONE : View.VISIBLE);
    holder.tvTitle2.setText(item.getMaterialKindName());//物料类别
    holder.tvContent1.setText(item.getMinbillno());//单据编号
    holder.tvContent2.setText(item.getRegDate());
    MyUtils.switchDataStutus(context, holder.tvStatus, item.getMinbillStatusCode());//数据状态
    holder.ivLogo.setText(MyStringUtil.substring(item.getStorageName(), 0, 2));//仓库
  }

  protected class ViewHolder extends BaseViewHolder {
    @BindView(R.id.iv_logo) CustomTextView ivLogo;
    @BindView(R.id.tv_title1) TextView tvTitle1;
    @BindView(R.id.tv_status) TextView tvStatus;
    @BindView(R.id.tv_title2) TextView tvTitle2;
    @BindView(R.id.tv_content1) TextView tvContent1;
    @BindView(R.id.tv_content2) TextView tvContent2;

    ViewHolder(View view) {
      super(view);
      ButterKnife.bind(this, view);
    }
  }
}
